<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRefundAddress extends Migration
{
    private $tableName = 'refund_address';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable($this->tableName)) $this->create();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }

    private function create()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->engine = 'InnoDB';      // 设置存储引擎
            $table->charset = 'utf8';       // 设置字符集
            $table->collation  = 'utf8_general_ci';       // 设置排序规则

            $table->id();
            $table->string("name",32)->nullable(false)->default(null)->comment("收件人名称");
            $table->string("mobile",32)->nullable(false)->default(null)->comment("收件人电话");
            $table->string("address",255)->nullable(false)->default(null)->comment("收件人地址");
            $table->tinyInteger("is_delete")->nullable(false)->default(0)->comment("是否删除 0--否 1--是");
            $table->timestamps();
        });

        DB::statement("ALTER TABLE zzkj_{$this->tableName} comment '售后订单地址表'");
    }
}
